Keep more event controller api private
authorMatthias Clasen <mclasen@redhat.com>
Thu, 20 Feb 2020 22:22:03 +0000 (17:22 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 21 Feb 2020 05:51:03 +0000 (00:51 -0500)
We don't want to expose the GtkCrossingData struct, and manually
feeding events to event controllers is not something we want to
encourage, going forward.

gtk/gtkenums.h
gtk/gtkeventcontroller.h
gtk/gtkeventcontrollerfocus.c
gtk/gtkeventcontrollerfocus.h
gtk/gtkeventcontrollermotion.c
gtk/gtkeventcontrollermotion.h
gtk/gtkeventcontrollerprivate.h
gtk/gtkwidgetprivate.h

index 59eb3e17c648e9c10d348a6223d3eabc42706393..d4c3b4de2b140896634ed02e7f929fa7fa398724 100644 (file)
@@ -954,16 +954,6 @@ typedef enum
   GTK_EVENT_SEQUENCE_DENIED
 } GtkEventSequenceState;
 
-typedef enum {
-  GTK_CROSSING_FOCUS,
-  GTK_CROSSING_POINTER
-} GtkCrossingType;
-
-typedef enum {
-  GTK_CROSSING_IN,
-  GTK_CROSSING_OUT
-} GtkCrossingDirection;
-
 /**
  * GtkPanDirection:
  * @GTK_PAN_DIRECTION_LEFT: panned towards the left
index 2cd8167c0353400ba8c4d157e9f07b4d1d37bd9c..6bdcfbb678fa89274d5ce4fd7d168a24c7bd4144 100644 (file)
@@ -40,37 +40,6 @@ G_BEGIN_DECLS
 #define GTK_EVENT_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_EVENT_CONTROLLER, GtkEventControllerClass))
 
 
-typedef struct _GtkCrossingData GtkCrossingData;
-
-/**
- * GtkCrossingData:
- * @type: the type of crossing event
- * @direction: whether this is a focus-in or focus-out event
- * @mode: the crossing mode
- * @old_target: the old target
- * @old_descendent: the direct child of the receiving widget that
- *     is an ancestor of @old_target, or %NULL if @old_target is not
- *     a descendent of the receiving widget
- * @new_target: the new target
- * @new_descendent: the direct child of the receiving widget that
- *     is an ancestor of @new_target, or %NULL if @new_target is not
- *     a descendent of the receiving widget
- *
- * The struct that is passed to gtk_event_controller_handle_crossing().
- *
- * The @old_target and @new_target fields are set to the old or new
- * focus or hover location.
- */
-struct _GtkCrossingData {
-  GtkCrossingType type;
-  GtkCrossingDirection direction;
-  GdkCrossingMode mode;
-  GtkWidget *old_target;
-  GtkWidget *old_descendent;
-  GtkWidget *new_target;
-  GtkWidget *new_descendent;
-};
-
 GDK_AVAILABLE_IN_ALL
 GType               gtk_crossing_data_get_type (void) G_GNUC_CONST;
 
@@ -81,17 +50,6 @@ GType        gtk_event_controller_get_type       (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkWidget  * gtk_event_controller_get_widget     (GtkEventController *controller);
 
-GDK_AVAILABLE_IN_ALL
-gboolean     gtk_event_controller_handle_event   (GtkEventController *controller,
-                                                  GdkEvent           *event,
-                                                  GtkWidget          *target,
-                                                  double              x,
-                                                  double              y);
-GDK_AVAILABLE_IN_ALL
-void         gtk_event_controller_handle_crossing (GtkEventController    *controller,
-                                                   const GtkCrossingData *crossing,
-                                                   double                 x,
-                                                   double                 y);
 GDK_AVAILABLE_IN_ALL
 void         gtk_event_controller_reset          (GtkEventController *controller);
 
index 0cec4344e9d29f326bbe6699a4956da6dc322da3..a8a6aaa29649af4631ea45468e676e21b4fa963b 100644 (file)
@@ -46,8 +46,6 @@ struct _GtkEventControllerFocus
 {
   GtkEventController parent_instance;
 
-  const GtkCrossingData *current_crossing;
-
   guint is_focus       : 1;
   guint contains_focus : 1;
 };
@@ -148,16 +146,8 @@ gtk_event_controller_focus_handle_crossing (GtkEventController    *controller,
                                             double                 x,
                                             double                 y)
 {
-  GtkEventControllerFocus *focus = GTK_EVENT_CONTROLLER_FOCUS (controller);
-
-  if (crossing->type != GTK_CROSSING_FOCUS)
-    return;
-
-  focus->current_crossing = crossing;
-
-  update_focus (controller, crossing);
-
-  focus->current_crossing = NULL;
+  if (crossing->type == GTK_CROSSING_FOCUS)
+    update_focus (controller, crossing);
 }
 
 static void
@@ -295,64 +285,6 @@ gtk_event_controller_focus_new (void)
   return g_object_new (GTK_TYPE_EVENT_CONTROLLER_FOCUS, NULL);
 }
 
-/**
- * gtk_event_controller_focus_get_focus_origin:
- * @controller: a #GtkEventControllerFocus
- *
- * Returns the widget that was holding focus before.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerFocus::focus-in and #GtkEventControllerFocus::focus-out signals.
- *
- * Returns: (transfer none): the previous focus
- */
-GtkWidget *
-gtk_event_controller_focus_get_focus_origin (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_target;
-}
-
-/**
- * gtk_event_controller_focus_get_focus_target:
- * @controller: a #GtkEventControllerFocus
- *
- * Returns the widget that will be holding focus afterwards.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerFocus::focus-in and #GtkEventControllerFocus::focus-out signals.
- *
- * Returns: (transfer none): the next focus
- */
-GtkWidget *
-gtk_event_controller_focus_get_focus_target (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_target;
-}
-
-GtkWidget *
-gtk_event_controller_focus_get_old_focus_child (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_descendent;
-}
-
-GtkWidget *
-gtk_event_controller_focus_get_new_focus_child (GtkEventControllerFocus *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_FOCUS (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_descendent;
-}
-
 /**
  * gtk_event_controller_focus_contains_focus:
  * @self: a #GtkEventControllerFocus
index 3a4ae1b7fe04ae90028f7dba4f72b5d960f3a0ed..30b7c7d93ec32cc55ed0b11bbb2fc6b39a253e8f 100644 (file)
@@ -46,15 +46,6 @@ GType               gtk_event_controller_focus_get_type  (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkEventController *gtk_event_controller_focus_new (void);
 
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_focus_origin   (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_focus_target   (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_old_focus_child (GtkEventControllerFocus  *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_focus_get_new_focus_child (GtkEventControllerFocus  *controller);
-
 GDK_AVAILABLE_IN_ALL
 gboolean            gtk_event_controller_focus_contains_focus     (GtkEventControllerFocus  *self);
 GDK_AVAILABLE_IN_ALL
index 3adbad42b963e12581b1eb6025863845c351d488..d0182cbcc0a46618694e561d88003fb95d97ee78 100644 (file)
@@ -303,48 +303,6 @@ gtk_event_controller_motion_new (void)
                        NULL);
 }
 
-/**
- * gtk_event_controller_motion_get_pointer_origin:
- * @controller: a #GtkEventControllerMotion
- *
- * Returns the widget that contained the pointer before.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerMotion::enter or
- * #GtkEventControllerMotion::leave signals.
- *
- * Returns: (transfer none): the previous pointer focus
- */
-GtkWidget *
-gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->old_target;
-}
-
-/**
- * gtk_event_controller_motion_get_pointer_target:
- * @controller: a #GtkEventControllerMotion
- *
- * Returns the widget that will contain the pointer afterwards.
- *
- * This function can only be used in handlers for the
- * #GtkEventControllerMotion::enter or
- * #GtkEventControllerMotion::leave signals.
- *
- * Returns: (transfer none): the next pointer focus
- */
-GtkWidget *
-gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller)
-{
-  g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER_MOTION (controller), NULL);
-  g_return_val_if_fail (controller->current_crossing != NULL, NULL);
-
-  return controller->current_crossing->new_target;
-}
-
 /**
  * gtk_event_controller_motion_contains_pointer:
  * @self: a #GtkEventControllerMotion
index dbbc8c5621ccdecd959e16dc5d4bb3daef5e2235..5fbcffe3b6a81c7b7fa922997b6871bc470238ee 100644 (file)
@@ -45,11 +45,6 @@ GType               gtk_event_controller_motion_get_type (void) G_GNUC_CONST;
 GDK_AVAILABLE_IN_ALL
 GtkEventController *gtk_event_controller_motion_new      (void);
 
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_motion_get_pointer_origin (GtkEventControllerMotion *controller);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *         gtk_event_controller_motion_get_pointer_target (GtkEventControllerMotion *controller);
-
 GDK_AVAILABLE_IN_ALL
 gboolean            gtk_event_controller_motion_contains_pointer   (GtkEventControllerMotion *self);
 GDK_AVAILABLE_IN_ALL
index 1ae4808f48943a7bff7adf692484bb34ba9c50cf..e9e17f14e4aeef36a0fbdeeb31a8ca1384593b11 100644 (file)
 
 #include "gtkeventcontroller.h"
 
+typedef enum {
+  GTK_CROSSING_FOCUS,
+  GTK_CROSSING_POINTER
+} GtkCrossingType;
+
+typedef enum {
+  GTK_CROSSING_IN,
+  GTK_CROSSING_OUT
+} GtkCrossingDirection;
+
+typedef struct _GtkCrossingData GtkCrossingData;
+
+/**
+ * GtkCrossingData:
+ * @type: the type of crossing event
+ * @direction: whether this is a focus-in or focus-out event
+ * @mode: the crossing mode
+ * @old_target: the old target
+ * @old_descendent: the direct child of the receiving widget that
+ *     is an ancestor of @old_target, or %NULL if @old_target is not
+ *     a descendent of the receiving widget
+ * @new_target: the new target
+ * @new_descendent: the direct child of the receiving widget that
+ *     is an ancestor of @new_target, or %NULL if @new_target is not
+ *     a descendent of the receiving widget
+ *
+ * The struct that is passed to gtk_event_controller_handle_crossing().
+ *
+ * The @old_target and @new_target fields are set to the old or new
+ * focus or hover location.
+ */
+struct _GtkCrossingData {
+  GtkCrossingType type;
+  GtkCrossingDirection direction;
+  GdkCrossingMode mode;
+  GtkWidget *old_target;
+  GtkWidget *old_descendent;
+  GtkWidget *new_target;
+  GtkWidget *new_descendent;
+};
+
 struct _GtkEventController
 {
   GObject parent_instance;
@@ -58,4 +99,14 @@ struct _GtkEventControllerClass
 
 GtkWidget *gtk_event_controller_get_target (GtkEventController *controller);
 
+gboolean   gtk_event_controller_handle_event   (GtkEventController *controller,
+                                                GdkEvent           *event,
+                                                GtkWidget          *target,
+                                                double              x,
+                                                double              y);
+void       gtk_event_controller_handle_crossing (GtkEventController    *controller,
+                                                 const GtkCrossingData *crossing,
+                                                 double                 x,
+                                                 double                 y);
+
 #endif /* __GTK_EVENT_CONTROLLER_PRIVATE_H__ */
index b3519f04b8b27c8a57e3133cc907d6c8ae698cde..21a933606e88611625ce12cfc1f38356130b418e 100644 (file)
@@ -30,7 +30,7 @@
 #include "gtkactionmuxerprivate.h"
 #include "gtkcontainer.h"
 #include "gtkcsstypesprivate.h"
-#include "gtkeventcontroller.h"
+#include "gtkeventcontrollerprivate.h"
 #include "gtklistlistmodelprivate.h"
 #include "gtkrootprivate.h"
 #include "gtksizerequestcacheprivate.h"